[APPS][Connections Part 6] Build backend module graph during backend builds#353
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e118c97bcd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
89e014a to
6e7a15a
Compare
908d3d4 to
d7a3e8c
Compare
6e7a15a to
93ee73a
Compare
d7a3e8c to
cb0c1ca
Compare
1b1f8fa to
5e9d380
Compare
5ce434d to
67e2595
Compare
5e9d380 to
fc121d3
Compare
67e2595 to
ad770f4
Compare
4297d54 to
c0eab57
Compare
0e3d954 to
b941937
Compare
🎉 All green!❄️ No new flaky tests detected 🔗 Commit SHA: 31f9122 | Docs | Datadog PR Page | Give us feedback! |
c3f66bf to
a00cd6b
Compare
|
AI reviewer note: I moved the Vite/Rollup-specific module ID handling out of The core module graph code now assumes canonical app-local source module IDs. The Vite collector is responsible for adapting Rollup |
a00cd6b to
ce6fdd3
Compare
|
|
||
| export type StringLiteral = SimpleLiteral & { value: string }; | ||
|
|
||
| type TypeOnlyAwareNode = BaseNode & { importKind?: string; exportKind?: string }; |
There was a problem hiding this comment.
importKind and exportKind are not part of the base estree they are part of the typescript AST fyi.
ce6fdd3 to
4780d00
Compare
|
|
||
| type ImportCallExpression = SimpleCallExpression & { callee: { type: 'Import' } }; | ||
|
|
||
| const DISALLOWED_GRAPH_DIRS = new Set(['node_modules', 'dist', 'build', '.vite']); |
There was a problem hiding this comment.
build seems potentially something a user could name a folder. We have that folder name inside one of our repos for example.
Also should we include .yarn? Any other folders that we might want? Should this be configurable?
There was a problem hiding this comment.
Those are good questions. A given module would need to be referenced via an import. This DISALLOWED_GRAPH_DIRS is checked against each module path. Perhaps we should remove dist, build, .vite since they are unlikely to be referenced in an import statement and make sure we also cover yarn's package location as well.
There was a problem hiding this comment.
Oh yes, in that case, we may only need node_modules as any .yarn imports necessarily also includes node_modules inside the import path (after the .zip)
bfcb042
into
master

Motivation
Prepare backend connection ID analysis to use the same module graph that backend bundling already sees, without moving connection ID extraction into this PR.
Changes
This PR adds module graph collection to the backend build path used by both production builds and the dev server. During each backend build, the Vite collector observes Rollup
moduleParsedevents and records app-local, parseable source modules with their transformed ASTs, canonical module IDs, static dependency IDs, and unsupported local dependency facts.For example, this backend module:
Produces a collected module record shaped like this:
The Vite-specific adapter owns Rollup module ID normalization and virtual module filtering, while the backend AST module graph code works with canonical app-local module IDs. That keeps bundler details out of the reusable graph record layer.
This PR intentionally stops at building the graph. Traversing the graph to collect connection IDs from reachable modules is handled in the next PR in the stack. Existing same-file backend connection ID behavior remains unchanged.
QA Instructions
Updated the focused unit coverage for backend module graph record creation and Vite collector behavior. Also ran the apps plugin typecheck and lint coverage for the changed module graph and backend build integration paths.
Validated the change against a local test app to confirm backend functions still build and upload while existing same-file
allowedConnectionIdsbehavior remains unchanged.Blast Radius
This affects the apps plugin backend build path by collecting module graph metadata during backend builds. The collected graph is not used to change emitted
allowedConnectionIdsbehavior in this PR, so runtime behavior should remain unchanged.Documentation